/*
 * Tiled QML plugin
 * Copyright (C) 2010 Thorbjørn Lindeijer
 * Copyright (C) 2010 Nokia Corporation
 *
 * This file is part of the Tiled QML plugin.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MAPITEM_H
#define MAPITEM_H

#include <QDeclarativeItem>

#include <QList>
#include <QString>
#include <QStringList>

namespace Tiled {

class Map;

namespace Internal {

class MapRenderer;

} // namespace Internal
} // namespace Tiled

/**
 * A graphics item that displays a Map.
 */
class MapItem : public QDeclarativeItem
{
    Q_OBJECT

    Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)

public:
    MapItem(QDeclarativeItem *parent = 0);

    QString source() const { return mSource; }
    void setSource(const QString &source);

    QRectF boundingRect() const;
    void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}

signals:
    void sourceChanged(const QUrl &source);

public slots:
    QVariantList readCollisionObjects();
    QVariantList readGameObjects();

private:
    QString mSource;

    Tiled::Map *mMap;
    Tiled::Internal::MapRenderer *mRenderer;
};

QML_DECLARE_TYPE(MapItem)

#endif // MAPITEM_H
